<template>
  <div>
    <el-dialog
      title="基本信息"
      :visible.sync="dialogVisible"
      width="60%"
      @close="colse"
    >
      <el-form :model="clazzlist" label-width="80px">
        <el-row :gutter="24">
          <el-col :span="8" :offset="0">
            <el-form-item label="班级名称">
              <el-input v-model="clazzlist.className"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8" :offset="0">
            <el-form-item label="班级类型">
              <el-select
                v-model="clazzlist.type"
                style="width: 100%"
                placeholder="请选择班级类型"
              >
                <el-option
                  v-for="item in clazzOption"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8" :offset="0">
            <el-form-item label="班级描述">
              <el-input v-model="clazzlist.desc"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="24">
          <el-col :span="8" :offset="0">
            <el-form-item label="开班时间">
              <el-date-picker
                v-model="clazzlist.startTime"
                type="datetime"
                value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="选择日期时间"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8" :offset="0">
            <el-form-item label="结束时间">
              <el-date-picker
                v-model="clazzlist.endTime"
                type="datetime"
                value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="选择日期时间"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

      <span slot="footer">
        <el-button @click="dialogVisible = false">Cancel</el-button>
        <el-button type="primary" @click="add">添加</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import ClassApi from "@/api/reallclazz/index";
export default {
  data() {
    return {
      dialogVisible: false,

      clazzlist: {},
      clazzOption: [
        {
          value: "0",
          label: "前端",
        },
        {
          value: "1",
          label: "UI",
        },
      ],
    };
  },
  created() {},
  methods: {
    colse() {},
    add() {
      var api = null;
      if (this.clazzlist.id) {
        api = ClassApi.clazzupdate;
      } else {
        api = ClassApi.clazzsave;
      }
      var parms = {
        xyClassInfo: {
          ...this.newclazzlist,
        },
      };
      api(parms).then((res) => {});
    },
    opendialog(id) {
      this.dialogVisible = true;
      ClassApi.clazzdetail({ id }).then((res) => {
        this.newclazzlist = res.data;
      });
      this.$emit("getclazzlist");
      this.newclazzlist = {};
    },
  },
};
</script>
<style scoped  lang='scss'>
</style>